<?php
namespace app\admin\controller;

class AjaxUploads extends \think\Controller
{
	public function uploads(){
		
		 if (!empty($_FILES)) {
			 $upload = new \org\Upload();
			 $upload->maxSize  = 3145728 ;
			 $upload->saveRule = 'time';
			 $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg','zip','rar','doc','docx');
			 $upload->savePath = "public/uploads/";
			 
			 if(false == $info = $upload->uploadOne($_FILES['file'])) 
			 {
                 return;
			 }else{
				 echo json_encode($info[0]);
                 return;
			 }
		 }else {
             return;
		 }
		
    } 

	public function img(){
		
		 if (!empty($_FILES)) {
			 $upload = new \org\Upload();
			 $upload->maxSize  = 3145728 ;
			 $upload->saveRule = 'time';
			 $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');
			 $upload->savePath = "public/uploads/"; 
			 if(false == $info = $upload->uploadOne($_FILES['file'])) 
			 {
                 return;
			 }else{
				 echo json_encode($info[0]);
                 return;
			 }
		 }else {
             return;
		 }
		
    } 

	public function file(){
		 if (!empty($_FILES)) {
			 $upload = new \org\Upload();
			 $upload->maxSize  = 3145728 ;
			 $upload->saveRule = '';
			 $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg','zip','rar','doc','docx','pdf');
			 $upload->savePath = "public/uploads/";
			 if(false == $info = $upload->uploadOne($_FILES['file'])) 
			 {
                 return;
			 }else{
				 echo json_encode($info[0]);
                 return;
			 }
		 }else {
             return;
		 }
		
    } 
} 
